﻿using Microsoft.TeamFoundation.Server;
using System;
using System.Windows;
using System.Windows.Controls;
using System.ComponentModel;

namespace TFhisto.UI
{
    /// <summary>
    /// Interaction logic for Options.xaml
    /// </summary>
    public partial class TFSSelection : Window
    {
        public ProjectInfo TeamProject { get ; set ; }
        
        public TFSSelection()
        {
            InitializeComponent();
            tFSUserControl1.LoadRegisteredServers();
            tFSUserControl1.PropertyChanged += new PropertyChangedEventHandler(tFSUserControl1_PropertyChanged);
        }

        /// <summary>
        /// Indicates whether or not the checkbox is checked
        /// </summary>
        /// <param name="box">The checkbox to process</param>
        /// <returns>True if it is checked or false if it is not</returns>
        private bool ProcessRadioButton(RadioButton btn)
        {
            if ((btn.IsChecked != null) && (btn.IsChecked == true))
                return true;
            else
                return false;
        }

        private void tFSUserControl1_PropertyChanged(Object sender, PropertyChangedEventArgs args)
        {
            if (args.PropertyName.Equals("TeamProjects"))
            {
                if (tFSUserControl1.TeamProjects.Length > 0)
                {
                    TeamProject = tFSUserControl1.TeamProjects[0];
                }
                this.Close();
            }
        }
    }
}